]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
loginManager: Extend canSuspend() callback
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 26 May 2016 20:20:50 +0000 (22:20 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Fri, 27 May 2016 15:04:46 +0000 (17:04 +0200)
The underlying logind API does not only indicate whether suspend is
available, but also whether the user is eligible for executing the
operation without further authentication. This information can be
relevant, so pass it to the callback.

https://bugzilla.gnome.org/show_bug.cgi?id=725960

js/misc/loginManager.js

index 7db94d4061807ab3e2428eb2ebed5c2f2e2f7982..3e3df3753ce1075bc9cca7342e6ba811d9ed4d71 100644 (file)
@@ -134,10 +134,13 @@ const LoginManagerSystemd = new Lang.Class({
 
     canSuspend: function(asyncCallback) {
         this._proxy.CanSuspendRemote(function(result, error) {
-            if (error)
-                asyncCallback(false);
-            else
-                asyncCallback(result[0] != 'no' && result[0] != 'na');
+            if (error) {
+                asyncCallback(false, false);
+            } else {
+                let needsAuth = result[0] == 'challenge';
+                let canSuspend = needsAuth || result[0] == 'yes';
+                asyncCallback(canSuspend, needsAuth);
+            }
         });
     },
 
@@ -190,7 +193,7 @@ const LoginManagerDummy = new Lang.Class({
     },
 
     canSuspend: function(asyncCallback) {
-        asyncCallback(false);
+        asyncCallback(false, false);
     },
 
     listSessions: function(asyncCallback) {